#pragma once

#include "grpc_utils.h"
#include "grpc/proto/task_flow.grpc.pb.h"

class HmiClient final
    : public GrpcUtilsClientS<task_flow::TaskFlowServer::Stub>
{
public:
    using Ptr = std::shared_ptr<HmiClient>;
    using ConstPtr = std::shared_ptr<const HmiClient>;
    /// @brief  处理服务器发送的图形信息
    using MonitorCallback = std::function<void(const task_flow::GraphInfo &)>;
    HmiClient(const std::string &target);
    ~HmiClient();

    int start();
    void stop();
    void setCallback(MonitorCallback monitor_cb);
    bool isRunning() const { return is_running_; }

private:
    bool is_running_ = false;
    /// @brief 监控循环
    void monitorLoop();
    std::shared_ptr<std::thread> monitor_thread_;
    MonitorCallback monitor_cb_;
};